/*

	Run this file to execute full analysis. Files can also be run separately in the order they are listed.

*/

cd ${work}0_letters
do code\0_1_prepare.do
do code\0_2_figure_1.do

cd ${work}1_data
do code\1_1_firm.do
do code\1_2_fire.do
do code\1_3_export_import.do
do code\1_4_vars.do
do code\1_5_promotion.do
do code\1_6_public.do
do code\1_7_CN8_over_time.do

cd ${work}2_prepare
do code\2_0_input.do
cd ${work}2_prepare
do code\2_1_clean.do
do code\2_2_variables.do
do code\2_3_rename.do

cd ${work}3_lgkp
do 3_0_input.do
cd ${work}3_lgkp
global work_bmrs ${work}
do code\00_control.do
global work ${work_bmrs}
macro drop work_bmrs root code tables rootfile bootstrap empty ioweight ourestimates

cd ${work}4_reg_variables
do code\4_0_input.do
cd ${work}4_reg_variables
do code\4_1_samples.do
do code\4_2_productgroups.do
do code\4_3_export.do
do code\4_4_promotion.do
do code\4_5_promotion_product.do
do code\4_6_vars.do
do code\4_7_baci.do

cd ${work}5_reg_analysis
do code\5_0_input.do
cd ${work}5_reg_analysis
do code\5_1a_regsample_idt.do
do code\5_1b_balancesample_idt.do
do code\5_1c_regsample_ipdt.do
do code\5_1d_regsample_ipt.do
do code\5_1e_regsample_promoproduct_idt.do
do code\5_1f_regsample_promoproduct_ipdt.do
do code\5_1g_regsample_pdt.do
local alist "a b c d e f g 	     h i  j  k  l  m  n  o  p  q   r   s   t  "
local elist "1 2 3 4 5 6 7_a3_a4 8 a1 a1 a2 a5 a6 a7 a8 a9 a10 a11 a12 a13"

local alist "a b c d e f 	   g  h  i  j  k  l  m  n  o   p   q   r   s   t  "
local elist "1 2 3 4 5 6_a4_a5 a1 a1 a2 a3 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15"

local n=1
foreach a of local alist {
	local e : word `n' of `elist'
	if "`a'"!="g"	do code\5_2`a'_table_`e'.do
	if "`a'"=="g"	do code\5_2`a'_figure_`e'.do
	local ++n
}
do code\5_2u_costbenefit.do